﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace IURIP
{
    /// <summary>
    /// The IMapIten interface.
    /// </summary>
    public interface IMapItem
    {
        /// <summary>
        /// Gets the task.
        /// </summary>
        ITask Task { get; }
        /// <summary>
        /// Gets the target.
        /// </summary>
        ITarget Target { get; }
        /// <summary>
        /// Gets the map.
        /// </summary>
        IMap Map { get; }
        /// <summary>
        /// Gets the map item is a list or a field.
        /// </summary>
        bool IsList { get; }
        /// <summary>
        /// Gets the map item's name
        /// </summary>
        string Name { get; }
        /// <summary>
        /// Gets the block name of the map item. A list MapItem must have a DataBlockName
        /// </summary>
        string DataBlockName { get; }
        /// <summary>
        /// Gets the source xpath of the map item
        /// </summary>
        string SourceXPath { get; }
        /// <summary>
        /// Gets the parent map item
        /// </summary>
        IMapItem Parent { get; }
        /// <summary>
        /// Gets children map items.
        /// </summary>
        List<IMapItem> Children { get; }

        /// <summary>
        /// Initializes the map item with configuration file
        /// </summary>
        /// <param name="node"></param>
        void InitByConfiguration(XmlNode node);
        /// <summary>
        /// Gets a map item by its name. In one hierarchy, the name should be unique.
        /// </summary>
        /// <param name="name">The map item's name</param>
        /// <returns></returns>
        IMapItem GetMapItemByName(string name);
        /// <summary>
        /// Gets a map item list by its block name.
        /// </summary>
        /// <param name="blockName">The map item's block name</param>
        /// <returns></returns>
        List<IMapItem> GetListByBlockName(string blockName);
    }
}
